<template>
  <div class="list-table" style="height: 100%">
    <div class="area-header">
      <span class="area-header-title">{{ $t('CR Gain') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item :label="$t('出资人信息')" prop="lpId">
        <el-select v-model="queryParams.id" :placeholder="$t('出资人信息')" :multiple="true" filterable>
          <el-option
            v-for="item in lpList"
            :key="item.dictValue"
            :value="item.dictValue"
            :label="item.dictLabel"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('查询截止日')" prop="endTime">
        <DatePicker v-model="queryParams.endTime" :placeholder="$t('查询截止日')" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t("搜索") }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t("重置") }}</el-button>
      </el-form-item>
    </el-form>
    <iframe
      id="iframeVue"
      :src="url"
      width="100%"
      frameborder="no"
      border="0"
      style="height: 700px;overflow: auto;margin-right: -15px;padding-right: 10px"
      @load="closeLoading"
    />
  </div>
</template>

<script>
import { config } from '@/utils'
import { findLpList } from '@/api/fund/lpBase/lpBase'
import { getToken } from '@/utils/auth'

  export default {
        data() {
          return {
            url: '',
            // 遮罩层
            loading: true,
            // 回款时间区间
            queryDates: [],
            // 查询参数
            queryParams: {
              endTime: '',
              lpIds: ''
            },
            // 基金列表
            lpList: [],
            height: 0
          }
        },
      created() {
        this.height = $('.app-main').height() - 150
        findLpList().then(res => {
          this.lpList = res.data
        })
        this.getList()
      },
      methods: {
        getList() {
          this.queryParams.lpIds = ''
          if (this.queryParams.id.length > 0) {
            this.queryParams.id.forEach(item => {
              this.queryParams.lpIds = this.queryParams.lpIds + item + ','
            })
          }
          this.url = config.baseURL + '/ureport/preview?_u=dataBase:CR Gain.ureport.xml&Authorization=Bearer ' + getToken() +
            '&lpIds=' + this.queryParams.lpIds + '&endTime=' + this.queryParams.endTime
        },
        closeLoading() {
          this.loading = false
        },
        /** 搜索按钮操作 */
        queryHandle() {
          this.getList()
        },
        /** 重置按钮操作 */
        resetQuery() {
          this.resetForm('queryForm')
          // 回款时间区间
          this.queryDates = []
            // 查询参数
          this.queryParams = {
              endTime: '',
              lpIds: '',
              id: []
          }
          this.queryHandle()
        }
      }
    }
</script>

<style scoped>

</style>
